package com.hm.health.entity.arguments;

import android.os.Bundle;

import com.goodix.libromablecom.sdk.cardiff.arguments.InitArgumentsKeyEnum;
import com.goodix.utils.DefaultSpUtil;
import com.hm.health.MyApplication;

/**
 * Created by chenshi on 2020/2/24.
 */

public class InitArgumentsManager {
    private static final String PERFS_KEY_INIT_TYPE = "com.goodix.perfs_key_init_type";

    static InitArgumentsManager sInstance;

    public static InitArgumentsManager getsInstance() {
        if (null == sInstance) {
            sInstance = new InitArgumentsManager();
        }
        return sInstance;
    }

    public void setWorkMode(int workMode) {
        DefaultSpUtil.put(MyApplication.getContext(), PERFS_KEY_INIT_TYPE, workMode);
    }

    public int getWorkMode() {
        return DefaultSpUtil.getValueWithDefault(MyApplication.getContext(),
                PERFS_KEY_INIT_TYPE, InitArgumentsKeyEnum.AppWorkMode.APP_MODE.ordinal());
    }

    public Bundle getBundle() {

        Bundle bundle = new Bundle();

        // 功能组名称
        bundle.putString(InitArgumentsKeyEnum.ARG_FUNCTION_GROUP,
                InitArgumentsKeyEnum.FUNCTION_GROUP1);

        // 工作模式
        bundle.putInt(InitArgumentsKeyEnum.ARG_CHANGE_DEVICE_WORK_MODE,
                getWorkMode());

        // 是否加载配置
        boolean isLoadConfig = MyApplication.getHbdOptionIni().isLoadConfigFromSdcard();
        bundle.putBoolean(InitArgumentsKeyEnum.INIT_ARG_IS_LOAD_CONFIG_FROM_SDCARD,
                isLoadConfig);

        // 调试通道使能指令数据包
        byte[] datas = MyApplication.getHbdOptionIni().getEnableDebugProtData();
        bundle.putByteArray(InitArgumentsKeyEnum.CONNECT_ARG_DEBUG_PROT_DATA, datas);

        // 是否为内部版本
        bundle.putInt(InitArgumentsKeyEnum.ARG_APP_IS_INNER_VERSION, 0);

        return bundle;
    }
}
